package cn.suhaoblog.core.door;


import cn.suhaoblog.core.global.Global;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 通用返回
 *
 * @author rambler
 * @since 2019年7月2日 18:10:14
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class CommonResponse<T> {
    private Integer status;
    // 消息,成功消息或者失败消息
    private String msg;
    // 要返回的数据
    private T data;

//    public CommonResponse<T> status(Integer status) {
//        this.status = status;
//        return this;
//    }

    public CommonResponse<T> msg(String msg) {
        this.msg = msg;
        return this;
    }

    public CommonResponse<T> data(T data) {
        this.data = data;
        return this;
    }

    public CommonResponse<T> ok() {
        this.status = Global.CommonResponseStatus.SUCCESS_CODE;
        return this;
    }

    public CommonResponse<T> fail() {
        this.status = Global.CommonResponseStatus.FAIL_CODE;
        return this;
    }

}

